using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using Q.Framework.Utility;
using Q.Framework.Extension;

namespace Q.Framework.WebCode
{
    public class SearchMasterPageBase : MasterPageBase
    {
        public Boolean IsSearched { get; set; }
        public Int32? ItemsCount {get;set;}
        public event EventHandler RedirectPageInsert;
        public event EventHandler Search;
        public event EventHandler New;
        public event EventHandler Report;
        public Panel PanelContent
        {
            get
            {
                return this.FindControlsByType<Panel>().First(c => c.ID == "pnlAutoFormContent");
            }
            set
            {
                Panel place = this.FindControlsByType<Panel>().First(c => c.ID == "pnlAutoFormContent");
                place = value;
            }
        }

        public Panel PanelResult
        {
            get
            {
                return this.FindControlsByType<Panel>().First(c => c.ID == "pnlAutoFormResult");
            }
            set
            {
                Panel place = this.FindControlsByType<Panel>().First(c => c.ID == "pnlAutoFormResult");
                place = value;
            }
        }

        public SearchMasterPageBase()
        {
            
        }

        protected void DoPageRedirectInsert(object sender, EventArgs e)
        {
            Session.Add("PageSearch", this.Page.Request.Url.Segments.Last());
            RedirectPageInsert(sender, e);
        }

        protected void DoSearch(object sender, EventArgs e)
        {
            Search(sender, e);
        }

        protected void DoNew(object sender, EventArgs e)
        {
            New(sender, e);
        }

        protected void DoReport(object sender, EventArgs e)
        {
            Report(sender, e);
        }
    }
}